home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_05 / colton / flipy.c < prev    next >
C/C++ Source or Header  |  1995-02-21  |  778b  |  52 lines

  1. /*
  2.  * Listing 9 - flipy.c
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include "ips_image.h"
  7.  
  8. void flipy();
  9.  
  10. int
  11. main(argc, argv)
  12. int argc;
  13. char **argv;
  14. {
  15.     ips_header    header;
  16.     ips_image    image, newimage;
  17.  
  18.     if (argc<3) {
  19.         printf("Usage: %s infile outfile", argv[0]);
  20.         exit(1);
  21.     }
  22.  
  23.     ips_to_img(&header, &image, argv[1]);
  24.  
  25.     flipy(&header, &image, &newimage);
  26.  
  27.     img_to_ips(&header, &newimage, argv[2]);
  28.  
  29.     exit(0);
  30. }
  31.  
  32.  
  33.  
  34. void
  35. flipy(header, image, newimage)
  36. ips_header *header;
  37. ips_image  *image, *newimage;
  38. {
  39.     long cnt;
  40.  
  41.     memcpy(newimage->cmap, image->cmap, sizeof(XColor) * 256);
  42.  
  43.     newimage->data =
  44.         (unsigned char *)malloc(header->width *
  45.             header->height);
  46.  
  47.     for(cnt=0;cnt < header->width * header->height;cnt++)
  48.         newimage->data[cnt] =
  49.             image->data[(header->width * header->height) -
  50.             cnt];
  51. }
  52.